#ifndef __SUBSYSTEM_DISGUISE_BEHAVIOR_H__
#define __SUBSYSTEM_DISGUISE_BEHAVIOR_H__

#include <set>
#include <mutex>
#include "Engine/Point3.hpp"
#include "Subsystems/BlockBehaviors/SubsystemBlockBehavior.hpp"

using namespace PocketSurvival;
using namespace PocketSurvival::Engine;

namespace PocketSurvival
{
    class SubsystemTerrain;
}

/*

                            (0xFFFFC000)              (0x3C00)       (0x3FF)
                +-------------- data ---------------+ +light+ +---- contents ----+
                |                                   | |     | |                  |
    BlockValue: 0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0  0 0 0 0 0 0 0 0      (32 bit)

*/

namespace AntiMineralTrace
{

    enum GraniteDisguiseType
    {
        Granite_None,
        Granite_CoalOreBlock,
        Granite_CopperOreBlock
    };

    enum BasaltDisguiseType
    {
        Basalt_None,
        Basalt_IronOreBlock,
        Basalt_SulphurOreBlock,
        Basalt_DiamondOreBlock,
        Basalt_GermaniumOreBlock
    };

    enum SandstoneDisguiseType
    {
        Sandstone_None,
        Sandstone_SaltpeterOreBlock
    };

    // 原版地形反矿物透视
    class SubsystemDisguiseBehavior : public SubsystemBlockBehavior
    {
    protected:
        SubsystemTerrain *m_terrain;

    public:
        SubsystemDisguiseBehavior();

        static constexpr inline int32_t GetSpecial(int32_t data)
        {
            return (data >> 13);
        }

        static constexpr inline int32_t SetSpecail(int32_t data, int32_t special)
        {
            return (data & 0x1FFF | (special << 13));
        }

        virtual void load(const nlohmann::json &json) override;
        virtual void onNeighborBlockChanged(int32_t x, int32_t y, int32_t z, int32_t neighborX, int32_t neighborY, int32_t neighborZ) override;

        virtual const std::string &getName() const override;
    };

}

#endif
